//市场项目

// projectSwitch === 'false' ||
// attachmentStatus === 'false' ||
// operationFlag === 1 ||
// taskStatusOnOrOff === false ||
// !(!['审批中', '完成', '延期完成'].includes(taskStatus) && delFlag === 0 && !children?.length)
if (record.operationFlag === 1) {
    message.error('非该任务任务负责人')
} else if (record.attachmentStatus == 'false') {
    message.error('该任务未上传附件，请上传附件后重试')
} else if (record.taskStatusOnOrOff == false) {
    message.error('只有开启/上线的任务才能完成任务')
} else if (record.projectSwitch == 'false') {
    message.error('只有项目开启状态下的任务才能完成')
} else if ((record.taskStatus === '审批中' || record.taskStatus === '延期完成' || record.taskStatus === '完成') && record
    .delFlag === 0) {
    message.error(`任务状态为${record.taskStatus}的任务无法进行完成操作`)
} else if (record.isRiskOrNo == true) {
    message.error('该任务包含风险，请关闭风险后重试')
} else {
    current.value = record
    apiMap = {
        default: '/ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap',
        plat: '/ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap',
        market: '/ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap',
        deliver: '/ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap'
    }
    post(apiMap[pageType], {
        milepostId: current.value.milepostId
    }).then(({
        ppmCheckListMap
    }) => {
        const data = []
        let len = 0
        for (let key in ppmCheckListMap) {
            len += ppmCheckListMap[key].length || 0
            data.push({
                name: key,
                value: ppmCheckListMap[key]
            })
        }

        ppmCheckedListLen.value = len
        ppmCheckedList.value = []
        ppmCheckList.value = data
        stateLi.okVisible = true
    })
}
// 平台项目

// projectSwitch === 'false' ||
// attachmentStatus === 'false' ||
// operationFlag === 1 ||
// taskStatusOnOrOff === false ||
// !(!['审批中', '完成', '延期完成'].includes(taskStatus) && delFlag === 0 && !children?.length)
if (record.operationFlag === 1) {
    message.error('非该任务任务负责人')
} else if (record.attachmentStatus == 'false') {
    message.error('该任务未上传附件，请上传附件后重试')
} else if (record.taskStatusOnOrOff == false) {
    message.error('只有开启/上线的任务才能完成任务')
} else if (record.projectSwitch == 'false') {
    message.error('只有项目开启状态下的任务才能完成')
} else if ((record.taskStatus === '审批中' || record.taskStatus === '延期完成' || record.taskStatus === '完成') && record
    .delFlag === 0) {
    message.error(`任务状态为${record.taskStatus}的任务无法进行完成操作`)
} else if (record.isRiskOrNo == true) {
    message.error('该任务包含风险，请关闭风险后重试')
} else {
    current.value = record
    apiMap = {
        default: '/ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap',
        plat: '/ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap',
        market: '/ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap',
        deliver: '/ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap'
    }
    post(apiMap[pageType], {
        milepostId: current.value.milepostId
    }).then(({
        ppmCheckListMap
    }) => {
        const data = []
        let len = 0
        for (let key in ppmCheckListMap) {
            len += ppmCheckListMap[key].length || 0
            data.push({
                name: key,
                value: ppmCheckListMap[key]
            })
        }

        ppmCheckedListLen.value = len
        ppmCheckedList.value = []
        ppmCheckList.value = data
        stateLi.okVisible = true
    })
}
// 交付
// !finishPermission ||
// projectSwitch === 'false' ||
// attachmentStatus === 'false' ||
// operationFlag === 1 ||
// taskStatusOnOrOff === false ||
// !(!['审批中', '完成', '延期完成'].includes(taskStatus) && delFlag === 0 && !children?.length)
if (record.finishPermission == false || record.operationFlag === 1) {
    message.error('非该任务任务负责人')
} else if (record.attachmentStatus == 'false') {
    message.error('该任务未上传附件，请上传附件后重试')
} else if (record.taskStatusOnOrOff == false) {
    message.error('只有开启/上线的任务才能完成任务')
} else if (record.projectSwitch == 'false') {
    message.error('只有项目开启状态下的任务才能完成')
} else if (record.taskStatus === '审批中' || record.taskStatus === '延期完成' || record.taskStatus === '完成') {
    message.error(`任务状态为${record.taskStatus}的任务无法进行完成操作`)
} else if (record.isRiskOrNo == true) {
    message.error('该任务包含风险，请关闭风险后重试')
} else {
    current.value = record
    apiMap = {
        default: '/ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap',
        plat: '/ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap',
        market: '/ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap',
        deliver: '/ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap'
    }
    post(apiMap[pageType], {
        milepostId: current.value.milepostId
    }).then(({
        ppmCheckListMap
    }) => {
        const data = []
        let len = 0
        for (let key in ppmCheckListMap) {
            len += ppmCheckListMap[key].length || 0
            data.push({
                name: key,
                value: ppmCheckListMap[key]
            })
        }

        ppmCheckedListLen.value = len
        ppmCheckedList.value = []
        ppmCheckList.value = data
        stateLi.okVisible = true
    })
}
